import React, { PureComponent } from "react";
import store from "../store";
import { Provider } from "react-redux";

class App extends React.Component {
  // constructor(props) {
  //   super(props);
  //   this.state = store.getState();
  //   store.subscribe(this.stateChange);
  // }
  componentDidMount() {
    this.props.getTodoList();
  }
  //   状态改变的 处理函数
  stateChange = () => {
    // this.setState(store.getState());
  };

  //   store.subscribe(this.stateChange)
  handleChange = (e) => {
    this.props.getInputChangeAction(e.target.value);
  };
  handleButton = () => {
    this.props.getBtnClickAction();
  };
  render() {
    console.log("props", this.props);
    return (
      <Provider store={store}>
        <input value={this.props.inputValue} onChange={this.handleChange} />
        <button onClick={this.handleButton}>提交</button>
        {this.props.list.map((item, index) => (
          <li
            onClick={() => {
              this.props.getDeleteItemAction(index);
            }}
            key={item}
          >
            {item}
          </li>
        ))}
      </Provider>
    );
  }
}
export default App;
